﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Transactions {
    import Engine.Managers.*;
    import Classes.*;

    public class TMove extends TWorldState {

        protected var m_params:Object;
        protected var m_coinBonus:Number;
        protected var m_xpBonus:Number;
        protected var m_numBonus:int;

        public function TMove(_arg1:GameObject, _arg2:Object){
            var _local3:Array;
            var _local4:ItemBonus;
            this.m_params = _arg2;
            super(_arg1);
            this.m_numBonus = 0;
            this.m_coinBonus = 0;
            this.m_xpBonus = 0;
            if ((_arg1 is MapResource)){
                _local3 = ItemBonus.getBonuses(MapResource(_arg1));
                for each (_local4 in _local3) {
                    if (_local4.field == ItemBonus.COIN_YIELD){
                        this.m_numBonus++;
                        this.m_coinBonus = (this.m_coinBonus + _local4.percentModifier);
                    } else {
                        if (_local4.field == ItemBonus.XP_YIELD){
                            this.m_numBonus++;
                            this.m_xpBonus = (this.m_xpBonus + _local4.percentModifier);
                        };
                    };
                };
            };
        }
        override public function perform():void{
            signedWorldAction("move", this.m_params);
        }
        override protected function onWorldActionComplete(_arg1:Object):void{
            if ((((m_object is MapResource)) && (!((_arg1.numBonus == null))))){
                if (this.m_numBonus != _arg1.numBonus){
                    ErrorManager.addError(((((("Number of bonuses did not match for " + MapResource(m_object).getItem().name) + ", expected ") + this.m_numBonus) + ", received ") + _arg1.numBonus), ErrorManager.ERROR_REMOTEOBJECT_FAULT);
                } else {
                    if (this.m_coinBonus != _arg1.coinBonus){
                        ErrorManager.addError(((((("Bonus percent did not match for " + MapResource(m_object).getItem().name) + ", expected ") + this.m_coinBonus) + ", received ") + _arg1.coinBonus), ErrorManager.ERROR_REMOTEOBJECT_FAULT);
                    } else {
                        if (this.m_xpBonus != _arg1.xpBonus){
                            ErrorManager.addError(((((("XP bonus did not match for " + MapResource(m_object).getItem().name) + ", expected ") + this.m_xpBonus) + ", received ") + _arg1.absoluteBonus), ErrorManager.ERROR_REMOTEOBJECT_FAULT);
                        };
                    };
                };
            };
        }

    }
}//package Transactions 
